package com.linkoog.devtools.code_generator.database.domain;

import com.intellij.icons.AllIcons.Providers;
import com.intellij.openapi.util.Iconable;

import javax.swing.*;

public enum DbType implements Iconable {

    MYSQL("mysql",
            Providers.Mysql,
            "com.mysql.cj.jdbc.Driver",
            "127.0.0.1",
            "3306",
            "mysql",
            "def",
            false,
            "root",
            "jdbc:mysql://${host}:${port}/${database}?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&useInformationSchema=true&connectTimeout=3000"),


    ORACLE("oracle",
            Providers.Oracle,
            "oracle.jdbc.driver.OracleDriver",
            "127.0.0.1",
            "1521",
            "orcl",
            "def",
            false,
            "",
            "jdbc:oracle:thin:@${host}:${port}:${database}"),


    POSTGRE("postgresql",
            Providers.Postgresql,
            "org.postgresql.Driver",
            "127.0.0.1",
            "5432",
            "postgres",
            "public",
            true,
            "postgres",
            "jdbc:postgresql://${host}:${port}/${database}?currentSchema=${schema}")
    ;



    private String name;
    private Icon icon;
    private String driver;
    private String defaultHost;
    private String defaultPort;
    private String defaultDatabase;
    private String defaultSchema;
    private boolean defaultSchemaEdit;
    private String defaultUser;
    private String connectUrl;



    private DbType(String name, Icon icon, String driver,
                   String defaultHost, String defaultPort,
                   String defaultDatabase, String defaultSchema,
                   boolean defaultSchemaEdit,
                   String defaultUser,
                   String connectUrl){
        this.name = name;
        this.icon = icon;
        this.driver = driver;
        this.defaultHost = defaultHost;
        this.defaultPort = defaultPort;
        this.defaultDatabase = defaultDatabase;
        this.defaultSchema = defaultSchema;
        this.defaultSchemaEdit = defaultSchemaEdit;
        this.defaultUser = defaultUser;
        this.connectUrl = connectUrl;
    }

    @Override
    public Icon getIcon(int flags) {
        return icon;
    }

    public String getName() {
        return name;
    }

    public Icon getIcon() {
        return icon;
    }

    public String getDriver() {
        return driver;
    }

    public String getDefaultDatabase() {
        return defaultDatabase;
    }

    public String getConnectUrl() {
        return connectUrl;
    }

    public String getDefaultHost() {
        return defaultHost;
    }

    public String getDefaultPort() {
        return defaultPort;
    }

    public String getDefaultSchema() {
        return defaultSchema;
    }

    public boolean isDefaultSchemaEdit() {
        return defaultSchemaEdit;
    }

    public String getDefaultUser() {
        return defaultUser;
    }


}
